package com.stone.serverless.config.service;

import com.alibaba.nacos.api.annotation.NacosInjected;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.spring.util.NacosUtils;
import lombok.SneakyThrows;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @Description: TODO
 * @Author: MECHREVO
 * @Date: 2022/1/26 9:08
 * @Version: 1.0.0
 */
@Service
public class ConfigServiceImpl implements StoneConfigService {

    @NacosInjected
    private ConfigService configService;

    @Override
    @SneakyThrows
    public  Map<String, Object> getConfig(String dataId, String groupId) {
        String content = configService.getConfig(dataId, groupId, 3000);
        System.out.println(content);

        Map<String, Object> objectMap = NacosUtils.toProperties(content);
        return objectMap;
    }
}
